﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ElfTyping.Animations;
using ElfTyping.States.GameState.Entities;
using ElfTyping.General;
using Microsoft.Xna.Framework;

namespace ElfTyping.States.GameState.Effects
{
    public class ChestEffect : GameEffect
    {
        const float StartOpeningChestTime = 1f;
        const float StopOpeningChestTime = 3f;
        const float StopShowingItemTime = 5f;

        Animation ItemAnimation = new Animation(@"Textures\GameState\PuzzlePiece");

        public ChestEffect(Enemy enemy)
            : base()
        {
            CurrentAnimation = new ChestAnimation();
            DrawBox = enemy.DrawBox;
            TimeLeft = StopShowingItemTime;
        }

        public override void Tick(float dt)
        {           
            base.Tick(dt);

            if (TimeElapsed < StartOpeningChestTime)
            {
                CurrentAnimation.Reset();
            }
        }

        public override void Draw(Camera camera)
        {
            if (TimeElapsed >= StopOpeningChestTime) {
                Rectangle itemRect = DrawBox;
                itemRect.Offset(itemRect.Width/4, -itemRect.Height*3/4);
                itemRect.Width = itemRect.Width / 2;
                itemRect.Height = itemRect.Height / 2;
                ItemAnimation.Draw(camera, itemRect);
            }
            base.Draw(camera);
        }
    }
}
